package com.haust.leyou.config;

import com.haust.leyou.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Auther: csp1999
 * @Date: 2020/12/21/16:18
 * @Description: 拦截器配置类
 */
@Configuration
public class LeyouWebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 拦截所有路径，/* 是拦截一级路径 /** 是拦截所有
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**");
    }
}
